<?php 

/*
 * 
 * 
 */
 
 class view {
 	
	function __construct()
	{
		$this->template_dir = ROOTPATH.'template/';
		
	}
	
	function init($t=NULL){
		if($t != NULL){
			$this->template_dir = ROOTPATH.'spider/template/';
		}	
	}
	
	function load($template_file,$data=false,$ret=FALSE)
	{
		if(!file_exists($this->template_dir.$template_file.'.php'))
		{
			echo $this->template_dir.$template_file.'php';	
			echo 'template file no found';
			exit();
		}
		ob_start();
		if(is_array($data))
		{
			extract($data);
		}
		include($this->template_dir.$template_file.'.php');
		if($ret == TRUE)
		{
			$content = ob_get_contents();
			ob_end_clean();
			return $content;
		}else{
			ob_end_flush();
		}
	}
	
 }


